package com.itc.bi.controller.bigScreen;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itc.bi.dto.bigScreen.BigCrossTableQueryDTO;
import com.itc.bi.dto.bigScreen.BigScreenDataSetQueryDTO;
import com.itc.bi.query.BigScreenDataSetQuery;
import com.itc.bi.service.BigScreenDataSetService;
import com.itc.bi.vo.bigScreenVO.DataSetTreeVO;
import com.itc.bi.vo.bigScreenVO.ProDirDataSetVO;
import com.itc.bi.vo.bigScreenVO.ScreenDataSetColumnVO;
import com.itc.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * @BelongsProject: itc-airport-cloud
 * @BelongsPackage: com.itc.bi.controller.bigScreen
 * @Author: hecaiy
 * @CreateTime: 2024-07-12  09:54
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/bigCreenDataSet")
@Api(value = "大屏数据集(大屏)",tags = "大屏数据集(大屏)")
public class BigScreenDataSetController {

    @Autowired
    private BigScreenDataSetService bigScreenDataSetService;

    @PostMapping("/getScreenDataSetDataList")
    @ApiOperation(value = "获取大屏数据集数据")
    public R<JSONObject> getScreenDataSetDataList(@RequestBody BigScreenDataSetQueryDTO dto){
        return R.ok(bigScreenDataSetService.getScreenDataSetDataListCommon(dto));
    }

    @PostMapping("/getDataSetPage")
    @ApiOperation(value = "分页查询数据集")
    public R<Page<ProDirDataSetVO>> getDataSetPage(@RequestBody BigScreenDataSetQuery query){
        return R.ok(bigScreenDataSetService.getDataSetPage(query.getType(),query.getName(),query.getPageIndex(),query.getPageSize()));
    }

    @GetMapping("/getTypeList")
    @ApiOperation(value = "获取数据集类型")
    public R<List<HashMap<String, Object>>> getTypeList(){
        return R.ok(bigScreenDataSetService.getTypeList());
    }

    @GetMapping("/getColumnList/{dtId}")
    @ApiOperation(value = "获取数据集数据项")
    public R<ScreenDataSetColumnVO> getColumnList(@PathVariable("dtId") Long dtId){
        return R.ok(bigScreenDataSetService.getColumnList(dtId));
    }

    @GetMapping("/getDataSetTree")
    @ApiOperation(value = "获取大屏数据集树")
    public R<List<DataSetTreeVO>> getDataSetTree(){
        return R.ok(bigScreenDataSetService.getDataSetTree());
    }

    @GetMapping("/getBigScreenDataSetList/{code}")
    @ApiOperation(value = "根据态势版本code获取数据集")
    public R<List<ProDirDataSetVO>> getBigScreenDataSetList(@PathVariable("code") String code){
        return R.ok(bigScreenDataSetService.getBigScreenDataSetList(code));
    }

    @PostMapping("/crossTableDataList")
    @ApiOperation(value = "交叉表获取数据")
    public R<JSONObject> crossTableDataList(@RequestBody BigCrossTableQueryDTO dto){
        return R.ok(bigScreenDataSetService.crosstable2(dto));
    }
}
